﻿<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
  
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>How-to: Filter Out Unwanted APIs or Attributes | DocFX website </title>
    <meta name="viewport" content="width=device-width">
    <meta name="title" content="How-to: Filter Out Unwanted APIs or Attributes | DocFX website ">
    <meta name="generator" content="docfx 2.37.0.0">
    
    <link rel="shortcut icon" href="../favicon.ico">
    <link rel="stylesheet" href="../styles/docfx.vendor.css">
    <link rel="stylesheet" href="../styles/docfx.css">
    <link rel="stylesheet" href="../styles/main.css">
    <meta property="docfx:navrel" content="../toc.html">
    <meta property="docfx:tocrel" content="toc.html">
    
    <meta property="docfx:rel" content="../">
    
  </head>
  <body data-spy="scroll" data-target="#affix" data-offset="120">
    <div id="wrapper">
      <header>
        
        <nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
          <div class="container">
            <div class="navbar-header">
              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
              </button>
              
              <a class="navbar-brand" href="../index.html">
                <img id="logo" class="svg" src="../logo.svg" alt="">
              </a>
            </div>
            <div class="collapse navbar-collapse" id="navbar">
              <form class="navbar-form navbar-right" role="search" id="search">
                <div class="form-group">
                  <input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
                </div>
              </form>
            </div>
          </div>
        </nav>
        
        <div class="subnav navbar navbar-default">
          <div class="container hide-when-search" id="breadcrumb">
            <ul class="breadcrumb">
              <li></li>
            </ul>
          </div>
        </div>
      </header>
      <div class="container body-content">
        
        <div id="search-results">
          <div class="search-list"></div>
          <div class="sr-items">
            <p><i class="glyphicon glyphicon-refresh index-loading"></i></p>
          </div>
          <ul id="pagination"></ul>
        </div>
      </div>
      <div role="main" class="container body-content hide-when-search">
        
        <div class="sidenav hide-when-search">
          <a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
          <div class="sidetoggle collapse" id="sidetoggle">
            <div id="sidetoc"></div>
          </div>
        </div>
        <div class="article row grid-right">
          <div class="col-md-10">
            <article class="content wrap" id="_content" data-uid="">
<h1 id="how-to-filter-out-unwanted-apis-or-attributes">How-to: Filter Out Unwanted APIs or Attributes</h1>

<p>A filter configuration file is in <a href="http://www.yaml.org/spec/1.2/spec.html">YAML</a> format. You may filter out unwanted APIs or attributes by providing a filter configuration file and specifying its path.</p>
<h2 id="specifying-the-filter-configuration-file-path">Specifying the filter configuration file path</h2>
<p>The path of the configuration file is specified in the following two ways. Option 1 could overwrite option 2.</p>
<ol>
<li><p>docfx.exe metadata command argument.</p>
<p><code>docfx.exe metadata --filter &lt;path relative to baseDir or absolutepath&gt;</code></p>
</li>
<li><p>docfx.json metadata section <code>filter</code> property.</p>
<p><strong>Sample</strong></p>
<pre><code>{
  &quot;metadata&quot;: [
    {
      &quot;src&quot;: [
        {
          &quot;files&quot;: [
            &quot;src/**.csproj&quot;
          ],
          &quot;exclude&quot;: [
            &quot;**/bin/**&quot;,
            &quot;**/obj/**&quot;
          ]
        }
      ],
      &quot;dest&quot;: &quot;obj/api&quot;,
      &quot;filter&quot;: &quot;filterConfig.yml&quot;
    }
  ]
}
</code></pre>
</li>
</ol>
<p>DocFX has a <a href="#3-default-filter-configuration">default filter configuration</a>. If the user doesn't specify the filter configuration file path, default filter configuration would be used. Otherwise, user provided filter configuration would merge with the default one. If there is a conflict, user specified would overwrite the default one.</p>
<h2 id="the-format-of-the-filter-configuration-file">The format of the filter configuration file</h2>
<h3 id="1-api-filter-rules">1. API Filter Rules</h3>
<p>To filter out APIs, you could specify <code>apiRules</code> with a list of <code>exclude</code> or <code>include</code> rules.</p>
<div class="NOTE">
<h5>Note</h5>
<p>The rules would be executed sequentially and the matching process would stop once one rule is matched.
Namely, you need to put the most detailed rule in the top.
If no rule is matched the API would be included by default.</p>
</div>
<h4 id="1-exclude-or-include-apis-by-matching-their-uid-with-the-regex-uidregex">1) <code>exclude</code> or <code>include</code> APIs by matching their uid with the Regex <code>uidRegex</code>.</h4>
<p>The sample below excludes all APIs whose uids start with 'Microsoft.DevDiv' except those that start with 'Microsoft.DevDiv.SpecialCase'.</p>
<pre><code>  - include:
      uidRegex: ^Microsoft\.DevDiv\.SpecialCase
  - exclude:
      uidRegex: ^Microsoft\.DevDiv
</code></pre>
<h4 id="2-exclude-or-include-apis-by-matching-its-type-this-is-often-combined-with-uidregex">2) <code>exclude</code> or <code>include</code> APIs by matching its <code>type</code>, this is often combined with <code>uidRegex</code>.</h4>
<p>Supported <code>type</code>:</p>
<ul>
<li><code>Namespace</code></li>
<li><code>Type</code></li>
<li><code>Class</code></li>
<li><code>Struct</code></li>
<li><code>Enum</code></li>
<li><code>Interface</code></li>
<li><code>Delegate</code></li>
<li><code>Member</code></li>
<li><code>Event</code></li>
<li><code>Field</code></li>
<li><code>Method</code></li>
<li><code>Property</code></li>
</ul>
<div class="NOTE">
<h5>Note</h5>
<p><code>Type</code> could be <code>Class</code>, <code>Struct</code>, <code>Enum</code>, <code>Interface</code>, or <code>Delegate</code>. <code>Member</code> could be <code>Event</code>, <code>Field</code>, <code>Method</code>, or <code>Property</code>.</p>
<p><code>Namespace</code> is flattened. Namely, excluding namespace 'A.B' has nothing to do with namespace 'A.B.C'.</p>
<p>If a namespace is excluded, all types/members defined in the namespace would also be excluded.
If a type is excluded, all members defined in the type would also be excluded.</p>
</div>
<p>The below sample would exclude all APIs whose uid starts with 'Microsoft.DevDiv' and type is <code>Type</code>, namely <code>Class</code>, <code>Struct</code>,
<code>Enum</code>, <code>Interface</code>, or <code>Delegate</code>.</p>
<pre><code>  - exclude:
      uidRegex: ^Microsoft\.DevDiv
      type: Type
</code></pre>
<h4 id="3-exclude-or-include-apis-by-containing-matched-attributes">3) <code>exclude</code> or <code>include</code> APIs by containing matched attributes.</h4>
<p>You can specify an attribute by its <code>uid</code>, <code>ctorArguments</code> and <code>ctorNamedArguments</code>.</p>
<blockquote>
<p><em>Note</em></p>
<p><code>ctorArguments</code> requires a full match of the attribute's constructor arguments, while <code>ctorNamedArguments</code> supports a partial match.
Namely, <code>ctorArguments</code> should contain all the arguments while <code>ctorNamedArguments</code> could contain a subset of the named arguments.</p>
</blockquote>
<p>The sample below excludes all APIs which have EditorBrowsableAttribute and its constructor argument is EditorBrowsableState.Never.</p>
<pre><code>  - exclude:
      hasAttribute:
        uid: System.ComponentModel.EditorBrowsableAttribute
        ctorArguments:
        - System.ComponentModel.EditorBrowsableState.Never
</code></pre>
<p>The sample below excludes all APIs which have AttributeUsageAttribute and its constructor argument is AttributeTargets.Class
and its constructor has named argument [Inherited] = true</p>
<pre><code>  - exclude:
    hasAttribute:
      uid: System.AttributeUsageAttribute
      ctorArguments:
      - System.AttributeTargets.Class
      ctorNamedArguments:
        Inherited: &quot;true&quot;
</code></pre>
<p>A complete <strong>Sample</strong> of the filter configuration file for filtering out APIs follows:</p>
<pre><code class="lang-yaml">apiRules:
- exclude:
    uidRegex: ^Microsoft\.TeamFoundation\.WorkItemTracking\.Proxy\.IRowSetsNative$
- exclude:
    uidRegex: ^Microsoft\.TeamFoundation\.WorkItemTracking\.Proxy\.MetadataRowSetsNative$
- exclude:
    uidRegex: ^Microsoft\.TeamFoundation\.WorkItemTracking\.Proxy\.RowSet\.Columns.*$
    type: Member
- exclude:
    uidRegex: ^Microsoft\.TeamFoundation\.WorkItemTracking\.Proxy\.RowSetColumn\.Name.*$
    type: Member
- exclude:
    hasAttribute:
      uid: System.ComponentModel.EditorBrowsableAttribute
      ctorArguments:
      - System.ComponentModel.EditorBrowsableState.Never
</code></pre>
<h3 id="2-attribute-filter-rules">2. Attribute Filter Rules</h3>
<p>To filter out Attributes, you could specify <code>attributeRules</code> with a list of <code>exclude</code> or <code>include</code> rules.</p>
<p>The rules are similar to API filter. Please refer to <a href="#1-api-filter-rules">API Filter Rules</a> section.</p>
<h3 id="3-default-filter-configuration">3. Default Filter Configuration</h3>
<pre><code class="lang-yaml">apiRules:
- exclude:
    hasAttribute:
      uid: System.ComponentModel.EditorBrowsableAttribute
      ctorArguments:
      - System.ComponentModel.EditorBrowsableState.Never
attributeRules:
- exclude:
    uidRegex: ^System\.ComponentModel\.Design$
    type: Namespace
- exclude:
    uidRegex: ^System\.ComponentModel\.Design\.Serialization$
    type: Namespace
- exclude:
    uidRegex: ^System\.Xml\.Serialization$
    type: Namespace
- exclude:
    uidRegex: ^System\.Web\.Compilation$
    type: Namespace
- exclude:
    uidRegex: ^System\.Runtime\.Versioning$
    type: Namespace
- exclude:
    uidRegex: ^System\.Runtime\.ConstrainedExecution$
    type: Namespace
- exclude:
    uidRegex: ^System\.EnterpriseServices$
    type: Namespace
- exclude:
    uidRegex: ^System\.Diagnostics\.CodeAnalysis$
    type: Namespace
- include:
    uidRegex: ^System\.Diagnostics\.(ConditionalAttribute|EventLogPermissionAttribute|PerformanceCounterPermissionAttribute)$
    type: Type
- exclude:
    uidRegex: '^System\.Diagnostics\.[^.]+$'
    type: Type
- include:
    uidRegex: ^System\.ComponentModel\.(BindableAttribute|BrowsableAttribute|ComplexBindingPropertiesAttribute|DataObjectAttribute|DefaultBindingPropertyAttribute|ListBindableAttribute|LookupBindingPropertiesAttribute|SettingsBindableAttribute|TypeConverterAttribute)$
    type: Type
- exclude:
    uidRegex: '^System\.ComponentModel\.[^.]+$'
    type: Type
- exclude:
    uidRegex: ^System\.Reflection\.DefaultMemberAttribute$
    type: Type
- exclude:
    uidRegex: ^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$
    type: Type
- include:
    uidRegex: ^System\.Runtime\.CompilerServices\.ExtensionAttribute$
    type: Type
- exclude:
    uidRegex: '^System\.Runtime\.CompilerServices\.[^.]+$'
    type: Type
- include:
    uidRegex: ^System\.Runtime\.InteropServices\.(ComVisibleAttribute|GuidAttribute|ClassInterfaceAttribute|InterfaceTypeAttribute)$
    type: Type
- exclude:
    uidRegex: '^System\.Runtime\.InteropServices\.[^.]+$'
    type: Type
- include:
    uidRegex: ^System\.Security\.(SecurityCriticalAttribute|SecurityTreatAsSafeAttribute|AllowPartiallyTrustedCallersAttribute)$
    type: Type
- exclude:
    uidRegex: '^System\.Security\.[^.]+$'
    type: Type
- include:
    uidRegex: ^System\.Web\.UI\.(ControlValuePropertyAttribute|PersistenceModeAttribute|ValidationPropertyAttribute|WebResourceAttribute|TemplateContainerAttribute|ThemeableAttribute|TemplateInstanceAttribute)$
    type: Type
- exclude:
    uidRegex: '^System\.Web\.UI\.[^.]+$'
    type: Type
- include:
    uidRegex: ^System\.Windows\.Markup\.(ConstructorArgumentAttribute|DesignerSerializationOptionsAttribute|ValueSerializerAttribute|XmlnsCompatibleWithAttribute|XmlnsDefinitionAttribute|XmlnsPrefixAttribute)$
    type: Type
- exclude:
    uidRegex: '^System\.Windows\.Markup\.[^.]+$'
    type: Type
</code></pre>
<div id="disqus_thread"></div>
                <script>
                (function() { // DON'T EDIT BELOW THIS LINE
                var d = document, s = d.createElement('script');
                s.src = 'https://docfx-github.disqus.com/embed.js';
                s.setAttribute('data-timestamp', +new Date());
                (d.head || d.body).appendChild(s);
                })();
                </script>
                <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
            </article>
          </div>
          
          <div class="hidden-sm col-md-2" role="complementary">
            <div class="sideaffix">
              <div class="contribution">
                <ul class="nav">
                  <li>
                    <a href="#disqus_thread" class="contribution-link">0 Comments</a>
                  </li>
                </ul>
              </div>
              <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
              <!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
              </nav>
            </div>
          </div>
        </div>
      </div>
      
      <footer>
        <div class="grad-bottom"></div>
        <div class="footer">
          <div class="container">
            <span class="pull-right">
              <a href="#top">Back to top</a>
            </span>
            <span>Copyright © 2015-2018 Microsoft<br>Generated by <strong>DocFX</strong></span>
            
          </div>
        </div>
      </footer>
    </div>
    
    <script type="text/javascript" src="../styles/docfx.vendor.js"></script>
    <script type="text/javascript" src="../styles/docfx.js"></script>
    <script type="text/javascript" src="../styles/main.js"></script>
    <script id="dsq-count-scr" src="//docfx-github.disqus.com/count.js" async=""></script>
    
    <script>
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
    
      ga('create', 'UA-99241001-1', 'auto');
      ga('send', 'pageview');
    
    </script>
  </body>
</html>
